# 策略模式

class cashsuper:
    def acceptcash(self, money):
        return 0


class CashNormal(cashsuper):
    def acceptcash(self, money):
        return money


class CashRebate(cashsuper):
    discount = 0

    def __init__(self, ds):
        self.discount = ds

    def acceptcash(self, money):
        return money * self.discount


class CashReturn(cashsuper):
    total = 0;
    ret = 0;

    def __init__(self, t, r):
        self.total = t
        self.ret = r

    def acceptcash(self, money):
        if (money >= self.total):
            return money - self.ret
        else:
            return money


class CashContext:
    def __init__(self, csuper):
        self.cs = csuper

    def getresult(self, money):
        return self.cs.acceptcash(money)


if __name__ == "__main__":
    money = input("money:")
    strategy = {}
    strategy[1] = CashContext(CashNormal())
    strategy[2] = CashContext(CashRebate(0.8))
    strategy[3] = CashContext(CashReturn(300, 100))
    ctype = input("type:[1]for normal,[2]for 80% discount [3]for 300 -100.")
    print(type(ctype))
    if int(ctype) in strategy:
        cc = strategy[ctype]
    else:
        print("Undefine type.Use normal mode.")
        cc = strategy[1]
    print("you will pay:%s" % (cc.getresult(money)))
